package com.cyy.content.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author cyy
 * @date 2025/2/23
 * @description RabbitMQConfig
 */
@Configuration
public class RabbitMQConfig {
    // 声明队列
    @Bean
    public Queue myQueue() {
        return new Queue("myQueue", true);  // 队列名，是否持久化
    }

    // 声明交换机（以 Direct 交换机为例）
    @Bean
    public DirectExchange myExchange() {
        return new DirectExchange("myExchange");
    }

    // 绑定队列到交换机
    @Bean
    public Binding binding(Queue myQueue, DirectExchange myExchange) {
        return BindingBuilder.bind(myQueue).to(myExchange).with("myRoutingKey");
    }

}
